connect = require '../utils/connect'

module.exports = 
	'get ': (req, res)->
		sql = "select * from singers where state = 1"
		singers = {}
		connect.runSql sql , (err, result)->
			console.log err if err
			result.forEach (singer)->
				singers[singer.first] = [] unless singers[singer.first]
				singers[singer.first].push singer

			shorts = []
			for first of singers
				shorts.push first

			res.render 'singer', {singers,shorts}